using System;
using MemoryPack;

namespace Hsenl.Network {
    public abstract class DisposableMessage : IDisposable {
        [MemoryPackIgnore]
        public bool IsCreateFromPool { get; set; }

        public void Dispose() {
            if (this.IsCreateFromPool) {
                Network.MessagePool.Return(this);
            }

            this.OnDisposed();
        }

        protected abstract void OnDisposed();
    }
}